package com.scenic.rd_android.testview.webview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.webkit.WebView;

import com.nova.scenic.projectlibs.util.debug.MyLog;
import com.scenic.rd_android.R;

public class RDWebViewActivity extends AppCompatActivity {

    static MyLog myLog = new MyLog("RDWebViewActivity");
    private WebView myWebView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rdweb_view);

        myWebView = (WebView) findViewById(R.id.webview);

        myWebView.loadUrl("http://www.baidu.com/");

    }


    //点击返回上一页面而不是退出浏览器
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && myWebView.canGoBack()) {
            myWebView.goBack();
            return true;
        }

        return super.onKeyDown(keyCode, event);
    }




}
